<!--
 * @description: 页头
 * @fileName: index
 * @author: 17076
 * @date: 2025/2/20-上午11:08
 * @version: V1.0.0
-->

<template>
  <div class="flex-row page-header">
    <div class="flex-row left-back" @click="handleBack">
      <i class="el-icon-arrow-left" />
      <span class="back-title">{{ title }}</span>
<!--      <el-divider v-if="content" direction="vertical"/>-->
      <span v-if="content" :title="content" class="content-title etc" @click.stop="handleEdit">{{ content }}</span>
      <i v-if="content && !hiddenEdit" class="el-icon-edit edit-button" @click.stop="handleEdit"/>
    </div>
    <slot name="center"/>
    <slot name="right"/>
  </div>
</template>

<script>
export default {
  name: 'Index',
  props: {
    title: {
      type: String,
      default: '返回'
    },
    content: {
      type: String,
      default: ''
    },
    // 隐藏编辑按钮
    hiddenEdit: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {}
  },
  methods: {
    // 返回
    handleBack() {
      this.$emit('back')
    },
    // 编辑
    handleEdit() {
      this.$emit('edit', this.content)
    }
  }
}
</script>

<style scoped lang="scss">
.page-header {
  background: $base-content-background;
  align-items: center;
  justify-content: space-between;
  color: $base-color-white;
  padding: 0 16px;
  min-height: 60px;
  line-height: 60px;
  border-radius: 8px;
  box-sizing: border-box;
  .left-back {
    align-items: center;
    cursor: pointer;
  }
  .back-title {
    font-size: 12px;
  }
  .content-title {
    font-weight: bold;
    margin-left: 10px;
    max-width: 260px;
  }
  .edit-button {
    margin-left: 10px;
    cursor: pointer;
  }
}
</style>
